$(function(){
	
	var $title 	= $('#title');
	var $content = $('#content');
	
	var $btnSubmit = $('#btnSubmit');
	$btnSubmit.click(function(){
		MessageAdd();
	});
});

//添加留言
function MessageAdd(){
	
	var $title 		= $('#title');
	var $content 	= $('#content');
	
	var title 		= $.trim($title.val());
	var content 	= $.trim($content.val());
	var type 		= $('input[name="type"]:checked').val();
	
	if(title == ''){
		alert('请填写主题');
		$title.focus();
		return;
	}
	
	if(content == ''){
		alert('请填写内容');
		$content.focus();
		return;
	}
	var url = '/index.php/Member/message_add';
	var params = {
		'type'		:type,
		'title'		:title,
		'content'	:content
	};
	
	$.post(url,params,function(data){
		if(data.success){
			alert('留言提交成功!');
			location.reload(true);
		}else{
			alert('留言提交失败!');
		}
	},'json');
}